package com.shihb.chapter03oop

object Demo06AbstractClass {
  def main(args: Array[String]): Unit = {
    // 默认情况下不能实例化
    // 匿名子类(实例化时动态的实现所有抽象)就可以
    val animal = new Animal {
      override var name: String = "tiger"
      override var age: Int = 2
      override def cry: Unit = {
        println(s"$name is cry")
      }
    }
    animal.cry
    println("ok")
  }

}
abstract class Animal{
  var name:String //抽象字段
  var age:Int//抽象字段
  var color="black"//普通属性
  def cry//抽象方法,不需要abstract
}
//要实现抽象属性和抽象方法
class Cat extends  Animal{
  override var name: String = "小猫"
  override var age: Int = _
  override def cry: Unit = {
    println(name+" 喵喵叫")
  }
}
